package  com.bawei.lib_net.interceptor

import okhttp3.Interceptor
import okhttp3.Response

/**
 * @author
 * @description 请求参数拦截器 接口url拼接
 * @date 2024/10/24
 */
class BasicParamsInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val originalRequest = chain.request()
        val originalHttpUrl = originalRequest.url
        val url = originalHttpUrl.newBuilder().apply {
            addQueryParameter("test","hahah")
//            addQueryParameter("udid", GlobalUtil.getDeviceSerial())
//            //针对开眼官方【首页推荐 】api 变动， 需要单独做处理。原因：附加 vc、vn 这两个字段后，请求接口无响应。
//            if (!originalHttpUrl.toString().contains(MainPageService.HOMEPAGE_RECOMMEND_URL)) {
//                addQueryParameter("vc", GlobalUtil.eyepetizerVersionCode.toString())
//                addQueryParameter("vn", GlobalUtil.eyepetizerVersionName)
//            }
//            addQueryParameter("size", screenPixel())
//            addQueryParameter("deviceModel", GlobalUtil.deviceModel)
//            addQueryParameter("first_channel", GlobalUtil.deviceBrand)
//            addQueryParameter("last_channel", GlobalUtil.deviceBrand)
//            addQueryParameter("system_version_code", "${Build.VERSION.SDK_INT}")
        }.build()
        val request = originalRequest.newBuilder().url(url).build()
        return chain.proceed(request)
    }
}
